package com.jh.fcsm.util;

/**
 *  驼峰转下划线
 */
public class CamelCaseToSnakeCase {

    public static String camelCaseToSnakeCase(String input) {
        StringBuilder result = new StringBuilder();
        if (input != null && !input.isEmpty()) {
            result.append(Character.toLowerCase(input.charAt(0)));
            for (int i = 1; i < input.length(); i++) {
                char currentChar = input.charAt(i);
                if (Character.isUpperCase(currentChar)) {
                    result.append("_").append(Character.toLowerCase(currentChar));
                } else {
                    result.append(currentChar);
                }
            }
        }
        return result.toString();
    }
}
